const {exec,escape} = require("../db/mysql");
const { SuccessModel,ErrorModel} = require("../model/resmodel");
const {genPassword} = require('../utils/cryp');
const login = (username,password)=>{
    username = escape(username);
    password = escape(password) ;
    //生成加密
    password = genPassword(password);
    console.log(password);
    let sql =  `select username,realname,password from users where username = ${username} and password='${password}';`;
    return exec(sql).then(dataList=>{
        console.log("datalist",dataList);
        return dataList[0]||{} ;
    })
}
module.exports  = {
    login
} ;
